package aqs;

import java.util.concurrent.locks.ReentrantLock;

public class AqsCodeDemo {

    public static void main(String[] args) {
        ReentrantLock lock = new ReentrantLock();
        new Thread(() -> {
            try {
                lock.lock();
                System.out.println("AAA来了");
                Thread.sleep(20);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                lock.unlock();
            }

        }, "A").start();
        new Thread(() -> {
            try {
                lock.lock();
                System.out.println("BBB来了");
                Thread.sleep(20);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                lock.unlock();
            }

        }, "B").start();
        new Thread(() -> {
            try {
                lock.lock();
                System.out.println("CcC来了");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                lock.unlock();
            }

        }, "C").start();

    }
}
